﻿@model PrivateMessageListModel 
@using Nop.Web;
@using Nop.Web.Extensions;
@using Nop.Web.Models.PrivateMessages;
<div class="private-messages-box">
    <script type="text/javascript">
        $(document).ready(function () {

            $('#selectallsent').click(function () {
                $('#pmsenttable .rowcheckbox').attr('checked', $(this).is(':checked')).change();
            });

            $('#pmsenttable .rowcheckbox').live('change', function (e) {
                var numChkBoxes = $('#pmsenttable .rowcheckbox').length;
                var numChkBoxesChecked = $('#pmsenttable .rowcheckbox:checked').length;
                $('#selectallsent').attr('checked', numChkBoxes == numChkBoxesChecked && numChkBoxes > 0);
            });
        });
    </script>
    @if (Model.Messages.Count > 0)
    {
        using (Html.BeginRouteForm("PrivateMessagesSent", FormMethod.Post))
        {
            
            
        <table class="pmgridtablestyle" cellspacing="0" cellpadding="4" id="pmsenttable">
            <col width="5%" />
            <col width="20%" />
            <col width="50%" />
            <col width="25%" />
            <thead>
                <tr class="pmgridheaderstyle">
                    <th class="a-center">
                        <input type="checkbox" id="selectallsent" />
                    </th>
                    <th class="a-center">
                        @T("PrivateMessages.Inbox.ToColumn")
                    </th>
                    <th class="a-center">
                        @T("PrivateMessages.Inbox.SubjectColumn")
                    </th>
                    <th class="a-center">
                        @T("PrivateMessages.Inbox.DateColumn")
                    </th>
                </tr>
            </thead>
            <tbody>
                @for (int i = 0; i < Model.Messages.Count; i++)
                {
                    var item = Model.Messages[i];
                    <tr @(i % 2 == 0 ? Html.Raw(" class=\"pmgridrowstyle\"") : Html.Raw(" class=\"pmgridaltrowstyle\""))>
                        <td class="a-center">
                            <input type="checkbox" name="si@(item.Id)" class="rowcheckbox" />
                        </td>
                        <td class="a-left">
                            @if (item.AllowViewingToProfile)
                            {
                                @Html.RouteLink(item.CustomerToName, "CustomerProfile", new { Id = item.ToCustomerId })
                            }
                            else
                            {
                                @item.CustomerToName
                            }
                        </td>
                        <td class="a-left">
                            @Html.RouteLink(item.Subject, "ViewPM", new { privateMessageId = item.Id }, new { @class = "pmread" })
                        </td>
                        <td class="a-left">
                            @item.CreatedOn
                        </td>
                    </tr>
                }
            </tbody>
        </table>
                if (Model.PagerModel.TotalPages > 1)
                {
        <div class="pmgridpagerstyle">
            @Html.Pager(Model.PagerModel)
        </div>
                }
        <div class="clear">
        </div>
        <div class="buttons">
            <button class="deleteselectedpmbutton" value="delete" name="sentupdate" type="submit">@T("PrivateMessages.Inbox.DeleteSelected")</button>
        </div>
        }
    }
</div>
